$(document).ready(function() {
    $('#slider').nivoSlider();
});

var map;
var vn_location = new Array();
vn_location['lat'] = 16.4549;
vn_location['lng'] = 106.5760;
function initialize() {
    var mapOptions = {
        zoom: 6,
        center: new google.maps.LatLng(vn_location['lat'], vn_location['lng']),
        mapTypeId: google.maps.MapTypeId.HYBRID,
        scrollwheel: false
    };
    map = new google.maps.Map(document.getElementById('home-map-canvas'), mapOptions);
  
    placeMarker();
}

google.maps.event.addDomListener(window, 'load', initialize);

function placeMarker() {
    console.log(ports);
    for (i = 0; i < ports.length; i++) {
        var port = ports[i];
        var latLng = new google.maps.LatLng( port.latitude, port.longitude);
        var marker = new google.maps.Marker({
            map: map,
            position: latLng,
            animation: google.maps.Animation.DROP,
            title: port.name
        }); 
        addClickHandler(marker, content = port.description);
    }
}

function addClickHandler(marker, description) {
    var infowindow = new google.maps.InfoWindow({
        content: description
    });    
    google.maps.event.addListener(marker, "click", function(){
        infowindow.open(map, marker);
    });           
}